package com.kfm.goods.mapper;

import com.kfm.goods.domain.Role;
import org.apache.ibatis.annotations.*;

/**
* @author 10854
* @description 针对表【role】的数据库操作Mapper
* @createDate 2023-11-08 14:57:46
* @Entity com.kfm.goods.domain.Role
*/
public interface RoleMapper {

    @Delete("delete from role where id = #{id}")
    int deleteByPrimaryKey(Long id);

    @Insert("insert into role (id, role_name, role_desc) values (#{id}, #{roleName}, #{roleDesc})")
    int insert(Role record);

    int insertSelective(Role record);


    @Select("select id role_id, role_name, role_desc from role where id = #{id}")
    @ResultMap("roleMap")
    Role selectByPrimaryKey(Long id);

    @Select("select id role_id, role_name, role_desc from role where id = #{id} and role_name = #{roleName}")
    // <resultMap>标签 使用注解 @Results()替代
    @Results(id = "roleMap", value={
            // @Result 代替 <id>/<result>标签  id=true 表示 id标签即主键
            @Result(property = "id", column = "role_id", id = true),
            @Result(property = "roleName", column = "role_name"),
            @Result(property = "roleDesc", column = "role_desc")
    })
    Role selectByIdAndRoleName(Integer id, @Param("roleName") String name);

    int updateByPrimaryKeySelective(Role record);

    @Update("update role set role_name = #{roleName}, role_desc = #{roleDesc} where id = #{id}")
    int updateByPrimaryKey(Role record);

}
